<?php
namespace app\admin\model;

use think\Model;
use think\facade\Db;

class Menu extends Model
{
    public $editFilterFields = ['id', 'url'];
    public $listFilterFields = ['create_time', 'update_time'];
    /**
     * 添加/编辑时特殊字段处理
     *
     * @param array $param
     * @param array $save
     * @return array
     */
    public function special($param = [], $save = [])
    {
        $save['url'] = '#';
        if(!empty($param['permission_id'])){
            $permission = Db::name('permission')->where('id', $param['permission_id'])->find();
            $save['url'] = $permission['controller'].'/'.$permission['action'];
        }
        return $save;
    }
}